package adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import fragments.FindingAll;
import fragments.FindingHot;
import fragments.FindingMyself;
import widget.TabIndicator;

/**
 * Created by Administrator on 2015/2/7.
 */
public  class FindingFragmentAdapter extends FragmentPagerAdapter implements TabIndicator.TabTextProvider {
    private final static  String TITLES[]={"全部","热门","我的"};

    public FindingFragmentAdapter(FragmentManager fm){super(fm);}

    @Override

    public  CharSequence getPageTitle(int position) {return TITLES[position];}

    @Override

    public int getCount() {return TITLES.length;}

    @Override

    public Fragment getItem(int position) {
        Fragment fm = null;
        switch (position) {
            case 0:
                fm = FindingAll.newInstance(position);
                break;
            case 1:
                fm = FindingHot.newInstance(position);
                break;
            case 2:
                fm = FindingMyself.newInstance(position);
                break;
            default:
                break;
        }
        return fm;
    }
    @Override
    public String getText(int position) {
        return FindingFragmentAdapter.TITLES[position % TITLES.length];
    }
}
